package org.familysearch.fsapi.gwt.server.dao.rest;

import java.io.DataInputStream;
import java.io.InputStream;
import java.io.Serializable;

import org.apache.commons.httpclient.HttpClient;
import org.familysearch.fsapi.gwt.common.Logger;
import org.familysearch.fsapi.gwt.server.dao.Session;

public class GenericRESTDAO<T, ID extends Serializable> {

	private static Logger log;
	protected Session session;
	protected HttpClient client = new HttpClient();
	
	public GenericRESTDAO()
	{
		log = Logger.getLogger(this.getClass().getName());
	}

	public Session getSession() {
		return session;
	}

	public void setSession(Session session) {
		this.session = session;
	}

	@SuppressWarnings("deprecation")
	protected String parseInputStream(InputStream inputStream)
	{
		DataInputStream dataInputStream = new DataInputStream(inputStream);
		StringBuffer sb = new StringBuffer();
		try
		{
			String line = null;
			while((line=dataInputStream.readLine()) != null)
			{
				sb.append(line+"\n");
			}
		}
		catch(Exception ex)
		{
			ex.getMessage();
		}
		finally
		{
			try
			{
				inputStream.close();
			}
			catch(Exception ex)
			{
				
			}
		}
		return sb.toString();
	}
}
